#!/bin/bash

echo "Matmul test begin..."
# if you install ascend with your own user, you should change the path to your own path
export ASCEND_HOME=/usr/local/Ascend/ascend-toolkit/latest

if [ ! -f ${ASCEND_HOME}"/bin/setenv.bash" ]; then
    echo "Error: The environment variable is not set."
    echo "Please install toolkit run package:"
    echo "https://www.hiascend.com/software/cann/community"
    exit 1
fi

# compile matmul kernel
source ${ASCEND_HOME}/bin/setenv.bash
python3 matmul_tik.py

if [ ! -f "kernel_meta/train_mmad_model.o" ]; then
    echo "Error: compile kernel failed."
    exit 1
fi

# make test main
cmake .
make

if [ ! -f "test.out" ]; then
    echo "Error: make test main failed."
    exit 1
fi

# run test
cp kernel_meta/train_mmad_model.o ./
./test.out


echo "Matmul test end..."